package com.notice.viewmodel;

import com.notice.model.MessageModel;
import com.notice.model.PhotoModel;
import com.notice.model.FileModel;
import com.notice.repository.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MessageViewModel extends BaseViewModel {
    
    @Autowired
    private MessageRepository messageRepository;
    
    public Integer addMessage(MessageModel message) {
        return messageRepository.add(message);
    }
    
    public List<MessageModel> searchMessages(MessageModel query) {
        return messageRepository.find(query);
    }
    
    public Object getMessageDetail(Integer mid) {
        return messageRepository.getDetail(mid);
    }
    
    public boolean deleteMessage(Integer mid) {
        return messageRepository.delete(mid);
    }
    
    public boolean updateMessage(MessageModel message) {
        return messageRepository.update(message);
    }
    
    public boolean addPhoto(PhotoModel photo) {
        return messageRepository.addPhoto(photo);
    }
    
    public boolean addFile(FileModel file) {
        return messageRepository.addFile(file);
    }
    
    public boolean updateFile(FileModel file) {
        return messageRepository.updateFile(file);
    }
    
    public boolean updatePhoto(PhotoModel photo) {
        return messageRepository.updatePhoto(photo);
    }
    
    public boolean deleteFile(FileModel file) {
        return messageRepository.deleteFile(file);
    }
    
    public boolean deletePhoto(PhotoModel photo) {
        return messageRepository.deletePhoto(photo);
    }
    
    public List<FileModel> findFiles(FileModel file) {
        return messageRepository.findFiles(file);
    }
    
    public List<PhotoModel> findPhotos(PhotoModel photo) {
        return messageRepository.findPhotos(photo);
    }
} 